<template>
  <div>
    <h3>这是购物车页面</h3>
    <br><br><br>
    <h3>这是购物车商品列表</h3>
    <table border="1">
      <tr>
        <th>商品名称</th>
        <th>价格</th>
        <th>数量</th>
        <th>小计</th>
      </tr>
      <tr v-for="item in list">
        <td>{{ item.bookname }}</td>
        <td>{{ item.price }}</td>
        <td>1</td>
        <td>{{ item.price}}</td>
      </tr>
    </table>
    <h2>总价：{{ z_prict }}</h2>
    <br><br><br>
    <table border="1">
      <tr>
        <th>优惠卷名称</th>
        <th>操作</th>
      </tr>
      <tr v-for="item in youhui">
        <td>满{{item.man}}减{{ item.jian}}</td>
        <td>
          <button type="submit">点击使用</button>
        </td>
      </tr>

    </table>
  </div>
</template>

<script>
    export default {
        data(){
            return{
                list:[],
                youhui:[],
                z_prict:0
            }
        },
        mounted() {
            this.axios.get('http://127.0.0.1:8000/gouwuche',{params:{
                  'username':localStorage.getItem('username')
                }}).then(res=>{
                    if (res.data.code == 200){
                        this.list = res.data.data;
                        this.z_prict = res.data.z_prict
                    }
            });
            this.axios.get('http://127.0.0.1:8000/youhuijuan',{params:{
                    'username':localStorage.getItem('username')
                }}).then(res=>{
                    if (res.data.code == 200){
                        this.youhui = res.data.data
                    }
            })
        }
    }
</script>

<style scoped>

</style>
